//
//  ZBInputAlertView.m
//  YouHui
//
//  Created by  on 11-12-13.
//  Copyright (c) 2011年 netease. All rights reserved.
//

#import "ZBInputAlertView.h"
#import "ZBPopViewContainer.h"

@implementation ZBInputAlertView

@synthesize inputTextField=_inputTextField;

-(id)initWithTitle:(NSString*)title delegate:(id)delegate buttons:(NSString*)buttonTitle,...{
    va_list otherTitles;
    va_start(otherTitles, buttonTitle); 
    self = [super initWithTitle:title delegate:delegate button:buttonTitle otherButtons:otherTitles];
    va_end(otherTitles);
    if (self) {
        _inputTextField =[[UITextField alloc] initWithFrame:CGRectZero];
        _inputTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        _inputTextField.borderStyle = UITextBorderStyleRoundedRect;
    }
    return self;
}

-(void)dealloc {
    [_inputTextField release];
    [super dealloc];
}

-(void)show {
    if (!self.contentView) {
        ZBInputAlertViewContainer *content = [[[ZBInputAlertViewContainer alloc] initWithFrame:CGRectZero] autorelease];
        content.parentPopView = self;
        [content addElements];
        [content setNeedsLayout];
        self.contentView = content;
        CGRect contentFrame = self.contentView.frame;
        contentFrame = CGRectOffset(contentFrame, 0, -80);
        self.contentView.frame = contentFrame;
    }
    [super show];
    [_inputTextField performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.2];
}

@end
